GitHub/GitLab Workflows
GitHub va GitLab nima?
GitHub va GitLab - bu Git repositorylaringizni internetda saqlash va boshqarish uchun platformalar. Bu xuddi kodingiz uchun "bulut xotira" kabi.
Farqi:
- GitHub - eng mashhur, Microsoft ga tegishli
- GitLab - ochiq manbali, ko'proq DevOps imkoniyatlari
Asosiy Tushunchalar
1. Remote Repository
Bu internetdagi repositoryingiz. Local kompyuteringizdan bu yerga kod yuklaysiz.
# Remote ni qo'shish
git remote add origin https://github.com/username/repo.git
# Remote larni ko'rish
git remote -v
2. Push va Pull
Push - Yuklash
# Local o'zgarishlarni remote ga yuklash
git push origin main
Pull - Yuklab olish
# Remote dan o'zgarishlarni olish
git pull origin main
GitHub/GitLab da Ish Jarayoni
1. Repository Yaratish
GitHub da:
- github.com ga kiring
- "New repository" ni bosing
- Nom va tavsif yozing
- Public/Private tanlang
- "Create repository"
GitLab da:
- gitlab.com ga kiring
- "New project" ni bosing
- "Create blank project"
- Ma'lumotlarni to'ldiring
2. Local bilan Bog'lash
# Yangi loyiha uchun
git init
git add .
git commit -m "Initial commit"
git remote add origin <URL>
git push -u origin main
# Mavjud loyihani clone qilish
git clone <URL>
Pull Request/Merge Request
Bu - o'zgarishlaringizni main branch ga qo'shishdan oldin ko'rib chiqish jarayoni.
Pull Request yaratish:
- Yangi branch yarating
git checkout -b feature/yangi-funksiya
- O'zgarishlar qiling va commit qiling
git add .
git commit -m "Yangi funksiya qo'shildi"
- Branch ni push qiling
git push origin feature/yangi-funksiya
- GitHub/GitLab da Pull Request oching
- "New Pull Request" tugmasini bosing
- Source va target branch ni tanlang
- Tavsif yozing
- Reviewerlar tanlang
Pull Request jarayoni:
Developer → Creates PR → Code Review → Approve/Changes → Merge
Issues va Project Management
Issues nima?
Bu - vazifalar, xatolar yoki takliflar uchun "tiket" tizimi.
Issue yaratish:
**Bug Report**
**Tavsif:** Login qilganda xato chiqadi
**Qadamlar:**
1. Login sahifasiga boring
2. Email va parol kiriting
3. "Login" tugmasini bosing
**Kutilgan natija:** Bosh sahifaga o'tish
**Haqiqiy natija:** Xato xabari chiqadi
**Screenshot:** [fayl]
Labels va Milestones
Labels:
🐛 bug - xatolar
✨ enhancement - yangiliklar
📝 documentation - hujjatlar
🚀 feature - yangi funksiyalar
Milestones:
📅 v1.0 Release - 2024-12-01
📅 Sprint 1 - 2024-11-15
GitHub Actions / GitLab CI/CD
GitHub Actions Misol:
# .github/workflows/test.yml
name: Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
GitLab CI/CD Misol:
# .gitlab-ci.yml
stages:
- test
- build
- deploy
test:
stage: test
image: node:18
script:
- npm install
- npm test
build:
stage: build
script:
- docker build -t myapp .
deploy:
stage: deploy
script:
- kubectl apply -f k8s/
only:
- main
Branch Protection Rules
Main branch ni himoya qilish uchun:
GitHub da:
- Settings → Branches
- "Add rule"
- Branch name:
main - ✅ Require pull request reviews
- ✅ Require status checks
- ✅ Require up-to-date branches
GitLab da:
- Settings → Repository → Push Rules
- ✅ Deny committing secrets to Git
- ✅ Restrict commits by author
- Protected Branches qo'shing
Forks va Contributions
Fork nima?
Bu boshqa odamning repositoryidan nusxa olish.
Fork workflow:
1. Fork qiling (GitHub da Fork tugmasi)
↓
2. Clone qiling
git clone <your-fork-url>
↓
3. Upstream qo'shing
git remote add upstream <original-repo>
↓
4. Branch yarating va ishlang
↓
5. Pull Request yuboring
Foydali GitHub/GitLab Features
1. Wiki
Loyiha hujjatlari uchun:
# Loyiha Hujjatlari
## O'rnatish
1. Repository ni clone qiling
2. `npm install` bajarib dependencies o'rnating
3. `.env` fayl yarating
## API
- `GET /api/users` - barcha userlar
- `POST /api/users` - yangi user yaratish
2. Projects/Boards
Kanban board uchun:
To Do → In Progress → Review → Done
3. Releases
Versiya chiqarish:
git tag v1.0.0
git push origin v1.0.0
Best Practices
1. README.md yozing
# Loyiha Nomi
## Tavsif
Bu loyiha nima qiladi
## O'rnatish
```bash
git clone <url>
npm install
npm start
Foydalanish
Qanday ishlatish...
Contributing
Qanday hissa qo'shish...
### 2. .gitignore faylini to'g'ri sozlang
```gitignore
# Dependencies
node_modules/
vendor/
# Environment
.env
.env.local
# Build
dist/
build/
# Logs
*.log
3. Commit messagelarini tartibli yozing
# Formatlar:
feat: yangi funksiya qo'shish
fix: xato tuzatish
docs: hujjat yangilash
style: kod formati
refactor: kod qayta yozish
test: test qo'shish
Xulosa
GitHub/GitLab workflows - bu zamonaviy dasturlashning asosi:
✅ Kod saqlash - xavfsiz va qulay ✅ Hamkorlik - jamoada ishlash ✅ CI/CD - avtomatik deploy ✅ Project Management - vazifalarni boshqarish ✅ Documentation - hujjatlashtirish
DevOps engineer sifatida bu platformalarni professional darajada bilish juda muhim!